#include <vector>
#include <iostream>
#include <stack>

int main()
{
    std::string num;
    int N;
    std::cin >> num;
    std::cin >> N;

    std::stack<char> sk;
    for (int i = 0; i < num.size(); i++)
    {
        while (!sk.empty() && N > 0 && sk.top() > num[i])
        {
            sk.pop();
            N--;
        }
        sk.push(num[i]);
    }

    while (N > 0)
    {
        sk.pop();
        N--;
    }

    std::string ret;
    while (!sk.empty())
    {
        ret = sk.top() + ret;
        sk.pop();
    }

    int st = 0;
    while (st < ret.size() && ret[st] == '0')
    {
        st++;
    }
    ret = ret.substr(st);
    std::cout << (ret.empty() ? "0" : ret) << std::endl;

    return 0;
}